package com.codechuan.hallo_internal.floatwindow.log;

public class LogManager {
    private boolean isLog = false;
    private LogTextureView logTextureView;

    private static class LogManagerHolder {
        private static final LogManager INSTANCE = new LogManager();
    }

    private LogManager() {
    }

    public static LogManager get() {
        return LogManagerHolder.INSTANCE;
    }

    public synchronized void startLog() {
        if (isLog) {
            return;
        }
        isLog = true;
        if (logTextureView != null) {
            logTextureView.start();
        }
    }

    public synchronized void stopLog() {
        isLog = false;
        if (logTextureView != null) {
            logTextureView.stop();
        }
    }

    public void initLog(LogTextureView logTextureView) {
        this.logTextureView = logTextureView;
    }

    public void addLog(String message) {
        if (logTextureView != null) {
            logTextureView.addLog(message);
        }
    }


}
